home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 5 / MACVOGL- / BUFFER.C < prev    next >
C/C++ Source or Header  |  1992-07-19  |  2KB  |  128 lines

  1. #include "vogl.h"
  2.  
  3. /*
  4.  * backbuffer
  5.  *
  6.  *    swap drawing to backbuffer - returns -1 if no
  7.  * backbuffer is available.
  8.  */
  9. void
  10. backbuffer(yes)
  11.     int    yes;
  12. {
  13.     Token    *tok;
  14.  
  15.     if (!vdevice.initialised)
  16.         verror("backbuffer: vogl not initialised");
  17.  
  18.     if (vdevice.inobject) {
  19.         tok = newtokens(2);
  20.         tok[0].i = BACKBUFFER;
  21.         tok[1].i = yes;
  22.         return;
  23.     }
  24.  
  25.     if (vdevice.attr->a.mode == SINGLE)
  26.         return;
  27.  
  28.     if (yes) {
  29.         if ((*vdevice.dev.Vbackb)() < 0)
  30.             verror("device doesn't support double buffering\n");
  31.         
  32.         vdevice.inbackbuffer = 1;
  33.     } else
  34.         vdevice.inbackbuffer = 0;
  35.     
  36. }
  37.  
  38. /*
  39.  * frontbuffer
  40.  *
  41.  *    start drawing in the front buffer again. This
  42.  * will always work!
  43.  */
  44. void
  45. frontbuffer(yes)
  46.     int    yes;
  47. {
  48.     Token    *tok;
  49.  
  50.     if (!vdevice.initialised)
  51.         verror("frontbuffer: vogl not initialised");
  52.  
  53.     if (vdevice.inobject) {
  54.         tok = newtokens(2);
  55.         tok[0].i = FRONTBUFFER;
  56.         tok[1].i = yes;
  57.         return;
  58.     }
  59.  
  60.     if (vdevice.attr->a.mode == SINGLE)
  61.         return;
  62.  
  63.     (*vdevice.dev.Vfrontb)();
  64.  
  65.     vdevice.inbackbuffer = 0;
  66. }
  67.  
  68. /*
  69.  * swapbuffers
  70.  *
  71.  *    swap the back and front buffers - returns -1 if
  72.  * no backbuffer is available.
  73.  */
  74. void
  75. swapbuffers()
  76. {
  77.     Token    *tok;
  78.  
  79.     if (vdevice.inobject) {
  80.         tok = newtokens(1);
  81.         tok[0].i = SWAPBUFFERS;
  82.         return;
  83.     }
  84.  
  85.     if (!vdevice.initialised)
  86.         verror("swapbuffers: vogl not initialised");
  87.  
  88.     if (vdevice.inbackbuffer != 1)
  89.         verror("swapbuffers: double buffering not initialised.\n");
  90.  
  91.     if ((*vdevice.dev.Vswapb)() < 0)
  92.         verror("device doesn't support double buffering\n");
  93. }
  94.  
  95. /*
  96.  * doublebuffer()
  97.  *
  98.  *    Flags our intention to do double buffering....
  99.  *    tries to set it up etc etc...
  100.  */
  101. void
  102. doublebuffer()
  103. {
  104.     if (!vdevice.initialised)
  105.         verror("doublebuffer: vogl not initialised");
  106.  
  107.     if ((*vdevice.dev.Vbackb)() < 0)
  108.         verror("device doesn't support double buffering\n");
  109.  
  110.     vdevice.inbackbuffer = 1;
  111. }
  112.  
  113. /*
  114.  * singlebuffer()
  115.  *
  116.  *    Goes back to singlebuffer mode....(crock)
  117.  */
  118. void
  119. singlebuffer()
  120.     if (vdevice.attr->a.mode == SINGLE)
  121.         return;
  122.  
  123.     (*vdevice.dev.Vfrontb)();
  124.  
  125.     vdevice.inbackbuffer = 0;
  126. }
  127.